package com.ruoyi.hospital.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.hospital.mapper.YlDoctorMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.hospital.mapper.YlScheduleMapper;
import com.ruoyi.hospital.domain.YlSchedule;
import com.ruoyi.hospital.service.IYlScheduleService;

/**
 * 排班信息Service业务层处理
 *
 * @author ruoyi
 * @date 2022-02-23
 */
@Service
public class YlScheduleServiceImpl implements IYlScheduleService
{
    @Autowired
    private YlScheduleMapper ylScheduleMapper;

    @Autowired
    private YlDoctorMapper ylDoctorMapper;

    /**
     * 查询排班信息
     *
     * @param schedulingId 排班信息主键
     * @return 排班信息
     */
    @Override
    public YlSchedule selectYlScheduleBySchedulingId(Long schedulingId)
    {
        return ylScheduleMapper.selectYlScheduleBySchedulingId(schedulingId);
    }

    /**
     * 查询排班信息列表
     *
     * @param ylSchedule 排班信息
     * @return 排班信息
     */
    @Override
    public List<YlSchedule> selectYlScheduleList(YlSchedule ylSchedule)
    {
        List<YlSchedule> ylScheduleList = ylScheduleMapper.selectYlScheduleList(ylSchedule);
        for (int i = 0; i< ylScheduleList.size(); i++){
            ylScheduleList.get(i).setName(ylDoctorMapper.selectYlDoctorByDoctorId(Long.valueOf(ylScheduleList.get(i).getDoctorId())).getName());
        }
        return ylScheduleList;
    }

    /**
     * 查询排班信息列表
     *
     * @return 排班信息
     */
    @Override
    public List<YlSchedule> selectAll()
    {
        return ylScheduleMapper.selectAll();
    }

    /**
     * 新增排班信息
     *
     * @param ylSchedule 排班信息
     * @return 结果
     */
    @Override
    public int insertYlSchedule(YlSchedule ylSchedule)
    {
        ylSchedule.setCreateTime(DateUtils.getNowDate());
        return ylScheduleMapper.insertYlSchedule(ylSchedule);
    }

    /**
     * 修改排班信息
     *
     * @param ylSchedule 排班信息
     * @return 结果
     */
    @Override
    public int updateYlSchedule(YlSchedule ylSchedule)
    {
        ylSchedule.setUpdateTime(DateUtils.getNowDate());
        return ylScheduleMapper.updateYlSchedule(ylSchedule);
    }

    /**
     * 批量删除排班信息
     *
     * @param schedulingIds 需要删除的排班信息主键
     * @return 结果
     */
    @Override
    public int deleteYlScheduleBySchedulingIds(Long[] schedulingIds)
    {
        return ylScheduleMapper.deleteYlScheduleBySchedulingIds(schedulingIds);
    }

    /**
     * 删除排班信息信息
     *
     * @param schedulingId 排班信息主键
     * @return 结果
     */
    @Override
    public int deleteYlScheduleBySchedulingId(Long schedulingId)
    {
        return ylScheduleMapper.deleteYlScheduleBySchedulingId(schedulingId);
    }
}
